import api from "../../api/index.js";

const state={
    product:[],
    sort:[]
};

const mutations={
    setProduct(state,nv){
        state.product=nv;
    },
    setSort(state,nv){
        state.sort=nv;
    }
};

const actions={
    loadProductAndSort({commit},params){
        api.loadThinkYourLike(params).then((data)=>{
            // console.log(data);
            if(!data.success){
                return Promise.reject("网络错误!");
            };
            commit("setProduct",data.result.wall.docs);
            commit("setSort",data.result.sortFilter);
        }).catch(api.showError);
    }
};

export default {
    state,
    mutations,
    actions
}

